/*
 * This file is part of Jmesh.
 *
 * last modified: October 02, 2001, 00:30 AM
 *
 */
package br.ufmg.dees.insane.ui.rich.learn.util.input_output_dialogs;

import java.awt.GridLayout;
import java.awt.Toolkit;

import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTable;

/**
 * A class representing creation dialog on screen.
 * This dialog is provided by some tabs
 * For example:
 * <pre>
 *    InpOutTableDialog dgl = new InpOutTableDialog(title, nLines, nTables);
 *    dlg.addInputTable(tableName, columnNames);	
 *    if(dlg.setVisible(true) == 0) table = dlg.getInputTable;
 * </pre>
 *
 * @author Pitangueira, Roque & Brugiolo, Marco 
 * @version 0.0.1 Beta  
 * @since jdk1.4.1
 */

public final class InputTableDialog extends TabbedDialog {
	
	private static final long serialVersionUID = 1L;
	private String title;
	private int nTables;
	private int nLines;
	private InputTableModel []tables;
	private String []tableNames;

	/**
	 * Constructor method.
	 *
	 * @param title   a dialog title.
	 * @param nLines  number of lines of all the tables.
	 * @param nTables number of tables.
	 * @see javax.swing
	 */
	public InputTableDialog(String title, int nTables, int nLines) {

		if(nLines <= 0 || title == null || nTables <=0){
		this.showErrorMessage("Erron in InpOutTableDialog constructor"
					+"\nTable Title = "+title
					+"\nNumber of Tables = "+nTables
					+"\nNumber of Lines = "+nLines);
		System.exit(0);
		}
		this.title = title;
		this.tables = new InputTableModel[nTables];
		this.tableNames = new String[nTables];
		this.nLines = nLines;
		this.nTables = 0;
	}

	/**
	 * Method to add an input table.
	 *
	 * @param name  a table name.
	 * @param colNames an array with the table column names.
	 * @see javax.swing
	 */
	public void addInputTable(String name, String[] colNames) {
		if(name == null || colNames == null){
		this.showErrorMessage("Erron in addInputTable method"
					+"\nTable Name = "+name
					+"\nColumn Names = "+colNames);
		System.exit(0);

		}	
		tableNames[nTables] = name;
		JPanel mainPane = new JPanel();
		mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS));
		JPanel linePane = new JPanel();
		linePane.setLayout(new GridLayout(1,colNames.length,0,0));
		for(int i=0; i < colNames.length; i++)
		{
			JButton button = new JButton(colNames[i]);
			linePane.add(button);
		}
		mainPane.add(linePane);

		JPanel tablePane = new JPanel();
		tablePane.setLayout(new GridLayout(1,1,0,0));
		tables[nTables] = new InputTableModel(nLines, colNames.length, colNames);
		JTable table = new JTable(tables[nTables]);
		tablePane.add(table);
		mainPane.add(tablePane);
		addTab(name, mainPane);
		nTables++;
	} //End of addInputTable


	/**
	 * Method to add an input table.
	 *
	 * @param name  a table name.
	 * @param colNames an array with the table column names.
	 * @param cells an 2D array with the cells of object type
	 * @see javax.swing
	 */
	public void addInputTable(String name, String[] colNames, Object[][]cells) {
		if(name == null || colNames == null || cells == null){
		this.showErrorMessage("Erron in addInputTable method"
					+"\nTable Name = "+name
					+"\nColumn Names = "+colNames
					+"\nCells = "+cells);
		System.exit(0);

		}	
		if(cells.length != nLines){
		this.showErrorMessage("Erron in addOutputTable method"
					+"\nThe Number of Lines have to be "+nLines);
		System.exit(0);
		}
		tableNames[nTables] = name;
		JPanel mainPane = new JPanel();
		mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS));
		JPanel linePane = new JPanel();
		linePane.setLayout(new GridLayout(1,colNames.length,0,0));
		for(int i=0; i < colNames.length; i++)
		{
			JButton button = new JButton(colNames[i]);
			linePane.add(button);
		}
		mainPane.add(linePane);

		JPanel tablePane = new JPanel();
		tablePane.setLayout(new GridLayout(1,1,0,0));
		tables[nTables] = new InputTableModel(nLines, colNames.length, colNames, cells);
		JTable table = new JTable(tables[nTables]);
		tablePane.add(table);
		mainPane.add(tablePane);
		addTab(name, mainPane);
		nTables++;
	} //End of addInputTable

	/**
	 * Method to add an input table.
	 *
	 * @param name  a table name.
	 * @param colNames an array with the table column names.
	 * @param cells an 2D array with the cells of double type
	 * @see javax.swing
	 */
	public void addInputTable(String name, String[] colNames, double[][]cells) {
		if(name == null || colNames == null || cells == null){
		this.showErrorMessage("Erron in addInputTable method"
					+"\nTable Name = "+name
					+"\nColumn Names = "+colNames
					+"\nCells = "+cells);
		}	
		if(cells.length != nLines){
		this.showErrorMessage("Erron in addOutputTable method"
					+"\nThe Number of Lines have to be "+nLines);
		System.exit(0);
		}

		Double objCells[][] = new Double[nLines][colNames.length];
		for(int i=0; i<nLines; i++)
			for(int j=0; j<colNames.length; j++){
			objCells[i][j] = new Double(cells[i][j]);
		}
		this.addInputTable(name, colNames, objCells);
	} //End of addInputTable

	/**
	 * Method to add an input table.
	 *
	 * @param name  a table name.
	 * @param colNames an array with the table column names.
	 * @param cells an 2D array with the cells of boolean type
	 * @see javax.swing
	 */
	public void addInputTable(String name, String[] colNames, boolean[][]cells) {
		if(name == null || colNames == null || cells == null){
		this.showErrorMessage("Erron in addInputTable method"
					+"\nTable Name = "+name
					+"\nColumn Names = "+colNames
					+"\nCells = "+cells);
		}	
		if(cells.length != nLines){
		this.showErrorMessage("Erron in addOutputTable method"
					+"\nThe Number of Lines have to be "+nLines);
		System.exit(0);
		}

		Boolean objCells[][] = new Boolean[nLines][colNames.length];
		for(int i=0; i<nLines; i++)
			for(int j=0; j<colNames.length; j++){
			objCells[i][j] = new Boolean(cells[i][j]);
		}
		this.addInputTable(name, colNames, objCells);
	} //End of addInputTable

	/**
	 * Method to add an input table.
	 *
	 * @param name  a table name.
	 * @param colNames an array with the table column names.
	 * @param cells an 2D array with the cells of integer type
	 * @see javax.swing
	 */
	public void addInputTable(String name, String[] colNames, int[][]cells) {
		if(name == null || colNames == null || cells == null){
		this.showErrorMessage("Erron in addInputTable method"
					+"\nTable Name = "+name
					+"\nColumn Names = "+colNames
					+"\nCells = "+cells);
		}	
		if(cells.length != nLines){
		this.showErrorMessage("Erron in addOutputTable method"
					+"\nThe Number of Lines have to be "+nLines);
		System.exit(0);
		}

		Integer objCells[][] = new Integer[nLines][colNames.length];
		for(int i=0; i<nLines; i++)
			for(int j=0; j<colNames.length; j++){
			objCells[i][j] = new Integer(cells[i][j]);
		}
		this.addInputTable(name, colNames, objCells);
	} //End of addInputTable

	/**
	 * Method to initialize an input table.
	 *
	 * @param table the position of the specified table on the tables array
	 * @param obj an 2D array with the cells table of type Object
	 * @see javax.swing
	 */
	public void initInputTable(int table, Object[][] obj) {
		if(table < 0){
		this.showErrorMessage("Erron in addInputTable method"
					+"\nTable Number = "+table);
		return;
		}	
		tables[table].initInputTable(obj);
	} //End of initInputTable

	/**
	 * Method to initialize an input table.
	 *
	 * @param table the position of the specified table on the tables array
	 * @param init a double value to initialize the cells table
	 * @see javax.swing
	 */
	public void initInputTable(int table, double init) {
		if(table < 0){
		this.showErrorMessage("Erron in addInputTable method"
					+"\nTable Number = "+table);
		return;
		}	
		int nC = tables[table].getColumnCount();
		Double objCells[][] = new Double[nLines][nC];
		for(int i=0; i<nLines; i++)
			for(int j=0; j<nC; j++)
			objCells[i][j] = new Double(init);
		this.initInputTable(table, objCells);
	} //End of initInputTable

	/**
	 * Method to initialize an input table.
	 *
	 * @param table the position of the specified table on the tables array
	 * @param init a integer value to initialize the cells table
	 * @see javax.swing
	 */
	public void initInputTable(int table, int init) {
		if(table < 0){
		this.showErrorMessage("Erron in addInputTable method"
					+"\nTable Number = "+table);
		return;
		}	
		int nC = tables[table].getColumnCount();
		Integer objCells[][] = new Integer[nLines][nC];
		for(int i=0; i<nLines; i++)
			for(int j=0; j<nC; j++)
			objCells[i][j] = new Integer(init);
		this.initInputTable(table, objCells);
	} //End of initInputTable

	/**
	 * Method to initialize an input table.
	 *
	 * @param table the position of the specified table on the tables array
	 * @param init a boolean value to initialize the cells table
	 * @see javax.swing
	 */
	public void initInputTable(int table, boolean init) {
		if(table < 0){
		this.showErrorMessage("Erron in addInputTable method"
					+"\nTable Number = "+table);
		return;
		}	
		int nC = tables[table].getColumnCount();
		Boolean objCells[][] = new Boolean[nLines][nC];
		for(int i=0; i<nLines; i++)
			for(int j=0; j<nC; j++)
			objCells[i][j] = new Boolean(init);
		this.initInputTable(table, objCells);
	} //End of initInputTable


	/**Method to initialize an input table column.
	 *
	 * @param table the position of the specified table on the tables array
	 * @param column the number of the column to be initialized
	 * @param cells a vector with the cells to initialize the column
	 * @see javax.swing
	 */
	public void initInputTableColumn(int table, int column, Object[]cells) {
		if(table < 0 || column < 0 || cells == null){
		this.showErrorMessage("Erron in addInputTable method"
					+"\nTable Number = "+table
					+"\nColumn Number = "+column
					+"\nCells = "+cells);
		System.exit(0);
		}	
		if(cells.length != nLines){
		this.showErrorMessage("Erron in initInputColumnTable method"
					+"\nThe Number of Lines have to be "+nLines);
		System.exit(0);
		}
		if(tables[table] == null){
			this.showErrorMessage("Erron in initInputTableColumn method"
					+"\nThe Table "+table+" not exist!");
			System.exit(0);
		}
		else tables[table].initInputTableColumn(column, cells);
	} //End of initInputTableColumn

	/**Method to initialize an input table column.
	 *
	 * @param table the position of the specified table on the tables array
	 * @param column the number of the column to be initialized
	 * @param init a double value to initialize the column
	 * @see javax.swing
	 */
	public void initInputTableColumn(int table, int column, double init) {
		if(table < 0 || column < 0){
		this.showErrorMessage("Erron in addInputTable method"
					+"\nTable Number = "+table
					+"\nColumn Number = "+column);
	
		System.exit(0);
		}	
		Double objCells[] = new Double[nLines];
		for(int i=0; i<nLines; i++)
			objCells[i] = new Double(init);
		this.initInputTableColumn(table, column, objCells);
	} //End of initInputTableColumn

	/**Method to initialize an input table column.
	 *
	 * @param table the position of the specified table on the tables array
	 * @param column the number of the column to be initialized
	 * @param init a integer value to initialize the column
	 * @see javax.swing
	 */
	public void initInputTableColumn(int table, int column, int init) {
		if(table < 0 || column < 0){
		this.showErrorMessage("Erron in addInputTable method"
					+"\nTable Number = "+table
					+"\nColumn Number = "+column);
	
		System.exit(0);
		}	
		Integer objCells[] = new Integer[nLines];
		for(int i=0; i<nLines; i++)
			objCells[i] = new Integer(init);
		this.initInputTableColumn(table, column, objCells);
	} //End of initInputTableColumn

	/**Method to initialize an input table column.
	 *
	 * @param table the position of the specified table on the tables array
	 * @param column the number of the column to be initialized
	 * @param init a boolean value to initialize the column
	 * @see javax.swing
	 */
	public void initInputTableColumn(int table, int column, boolean init) {
		if(table < 0 || column < 0){
		this.showErrorMessage("Erron in addInputTable method"
					+"\nTable Number = "+table
					+"\nColumn Number = "+column);
	
		System.exit(0);
		}	
		Boolean objCells[] = new Boolean[nLines];
		for(int i=0; i<nLines; i++)
			objCells[i] = new Boolean(init);
		this.initInputTableColumn(table, column, objCells);
	} //End of initInputTableColumn

	/**Method to initialize an input table column.
	 *
	 * @param table the position of the specified table on the tables array
	 * @param column the number of the column to be initialized
	 * @param cells a vector with the double values to initialize the column
	 * @see javax.swing
	 */
	public void initInputTableColumn(int table, int column, double[]cells) {
		if(table < 0 || column < 0 || cells == null){
		this.showErrorMessage("Erron in addInputTable method"
					+"\nTable Number = "+table
					+"\nColumn Number = "+column
					+"\nCells = "+cells);
		}	
		if(cells.length != nLines){
		this.showErrorMessage("Erron in initInputColumnTable method"
					+"\nThe Number of Lines have to be "+nLines);
		System.exit(0);
		}

		Double objCells[] = new Double[nLines];
		for(int i=0; i<nLines; i++)
			objCells[i] = new Double(cells[i]);
		this.initInputTableColumn(table, column, objCells);
	} //End of initInputTableColumn

	/**Method to initialize an input table column.
	 *
	 * @param table the position of the specified table on the tables array
	 * @param column the number of the column to be initialized
	 * @param cells a vector with the integer values to initialize the column
	 * @see javax.swing
	 */
	public void initInputTableColumn(int table, int column, int[]cells) {
		if(table < 0 || column < 0 || cells == null){
		this.showErrorMessage("Erron in addInputTable method"
					+"\nTable Number = "+table
					+"\nColumn Number = "+column
					+"\nCells = "+cells);
		}	
		if(cells.length != nLines){
		this.showErrorMessage("Erron in initInputColumnTable method"
					+"\nThe Number of Lines have to be "+nLines);
		System.exit(0);
		}

		Integer objCells[] = new Integer[nLines];
		for(int i=0; i<nLines; i++)
			objCells[i] = new Integer(cells[i]);
		this.initInputTableColumn(table, column, objCells);
	} //End of initInputTableColumn

	/**Method to initialize an input table column.
	 *
	 * @param table the position of the specified table on the tables array
	 * @param column the number of the column to be initialized
	 * @param cells a vector with the boolean values to initialize the column
	 * @see javax.swing
	 */
	public void initInputTableColumn(int table, int column, boolean[]cells) {
		if(table < 0 || column < 0 || cells == null){
		this.showErrorMessage("Erron in addInputTable method"
					+"\nTable Number = "+table
					+"\nColumn Number = "+column
					+"\nCells = "+cells);
		}	
		if(cells.length != nLines){
		this.showErrorMessage("Erron in initInputColumnTable method"
					+"\nThe Number of Lines have to be "+nLines);
		System.exit(0);
		}

		Boolean objCells[] = new Boolean[nLines];
		for(int i=0; i<nLines; i++)
			objCells[i] = new Boolean(cells[i]);
		this.initInputTableColumn(table, column, objCells);
	} //End of initInputTableColumn

	/** Method to configure an input table column as not editable.
	 *
	 * @param table the position of the specified table on the tables array
	 * @param column the number of the column to be initialized as not editable
	 * @see javax.swing
	 */
	public void setColumnNotEditable(int table, int column) {
		if(table < 0 || column < 0 ){
		this.showErrorMessage("Erron in addInputTable method"
					+"\nTable Number = "+table
					+"\nColumn Number = "+column);
		System.exit(0);
		}	
		tables[table].setColumnNotEditable(column);
	} //End of setColumnNotEditable

	/** Method to configure an input table cell as not editable.
	 *
	 * @param table the position of the specified table on the tables array
	 * @param row the number of the cell row to be initialized as not editable
	 * @param column the number of the cell column to be initialized as not editable
	  * @see javax.swing
	 */
	public void setCellNotEditable(int table, int row, int column) {
		if(table < 0 || column < 0 ){
		this.showErrorMessage("Erron in addInputTable method"
					+"\nTable Number = "+table
					+"\nColumn Number = "+column);
		System.exit(0);
		}	
		tables[table].setCellNotEditable(row, column);
	} //End of setCellNotEditable

	/**
	 * Method to get an input table.
	 *
	 * @param table the position of the specified table on the tables array
	 * @return an 2D array with the values typed by the user
	 * @see javax.swing
	 */
	public Object[][] getInputTable(int table) {
		if(table < 0){
		this.showErrorMessage("Erron in getInputTable method"
					+"\nTable Number = "+table);
		}	
		return(tables[table].getInputTable());
	} //End of getInputTable

	/**
	 * Method to get an input table.
	 *
	 * @param table the table number (0, 1,..., nTables).
	 * @return an 2D array with the values typed by the user as double
	 * @see javax.swing
	 */
	public double[][] getInputTableAsDouble(int table) {
		if(table < 0){
		this.showErrorMessage("Erron in getInputTableAsDouble method"
					+"\nTable Number = "+table);
		System.exit(0);
		}	
		int nc = tables[table].getColumnCount();
		double [][] cells = new double[nLines][nc];
		for(int i=0; i< nLines; i++)
			for(int j=0; j< nc; j++)
			try{
				cells[i][j] = ((Double)tables[table].getValueAt(i,j)).doubleValue();
			}
			catch(ClassCastException e){
					String msg = ""; 
					msg += "ERROR: "+e.getMessage(); 
					msg += "\n\n-----------------------"; 
					msg += "\n The value in the cell ("+i+", "+j+")"; 
					msg += "\n of the table "+tableNames[table]; 
					msg += "\n can not be converted to double"; 
					msg += "\n-----------------------"; 
					this.showErrorMessage(msg);
					this.showDialog();
					cells = this.getInputTableAsDouble(table);
			}
		return cells;
	} //End of getInputTableAsDouble

	/**
	 * Method to get an input table.
	 *
	 * @param table the table number (0, 1,..., nTables).
	 * @return an 2D array with the values typed by the user as integer
	 * @see javax.swing
	 */
	public int[][] getInputTableAsInt(int table) {
		if(table < 0){
		this.showErrorMessage("Erron in getInputTableAsDouble method"
					+"\nTable Number = "+table);
		System.exit(0);
		}	
		int nc = tables[table].getColumnCount();
		int [][] cells = new int[nLines][nc];
		for(int i=0; i< nLines; i++)
			for(int j=0; j< nc; j++)
			try{
				cells[i][j] = ((Integer)tables[table].getValueAt(i,j)).intValue();
			}
			catch(ClassCastException e){
					String msg = ""; 
					msg += "ERROR: "+e.getMessage(); 
					msg += "\n\n-----------------------"; 
					msg += "\n The value in the cell ("+i+", "+j+")"; 
					msg += "\n of the table "+tableNames[table]; 
					msg += "\n can not be converted to int"; 
					msg += "\n-----------------------"; 
					this.showErrorMessage(msg);
					this.showDialog();
					cells = this.getInputTableAsInt(table);
			}
		return cells;
	} //End of getInputTableAsInt

	/**
	 * Method to get an input table.
	 *
	 * @param table the table number (0, 1,..., nTables).
	 * @return an 2D array with the values typed by the user as boolean
	 * @see javax.swing
	 */
	public boolean[][] getInputTableAsBoolean(int table) {
		if(table < 0){
		this.showErrorMessage("Erron in getInputTableAsDouble method"
					+"\nTable Number = "+table);
		return null;
		}	
		int nc = tables[table].getColumnCount();
		boolean [][] cells = new boolean[nLines][nc];
		for(int i=0; i< nLines; i++)
			for(int j=0; j< nc; j++)
			try{
				cells[i][j] = ((Boolean)tables[table].getValueAt(i,j)).booleanValue();
			}
			catch(ClassCastException e){
					String msg = ""; 
					msg += "ERROR: "+e.getMessage(); 
					msg += "\n\n-----------------------"; 
					msg += "\n The value in the cell ("+i+", "+j+")"; 
					msg += "\n of the table "+tableNames[table]; 
					msg += "\n can not be converted to boolean"; 
					msg += "\n-----------------------"; 
					this.showErrorMessage(msg);
					this.showDialog();
					cells = this.getInputTableAsBoolean(table);
			}
		return cells;
	} //End of getInputTableAsBoolean

	/**
	 * Method to get an input table column.
	 *
	 * @param table the position of the specified table on the tables array
	 * @param column the number of the column
	 * @return vector with the values of the column typed by the user
	 * @see javax.swing
	 */
	public Object[] getInputTableColumn(int table, int column) {
		if(table < 0 || column < 0){
		this.showErrorMessage("Erron in getInputTable method"
					+"\nTable Number = "+table);
		return null;
		}	
		return(tables[table].getInputTableColumn(column));
	} //End of getInputTableColumn

	/**
	 * Method to get an input table column.
	 *
	 * @param table the position of the specified table on the tables array
	 * @param column the number of the column
	 * @return vector with the values of the column typed by the user as double
	 * @see javax.swing
	 */
	public double[] getInputTableColumnAsDouble(int table, int column) {
		if(table < 0 || column < 0){
		this.showErrorMessage("Erron in getInputTable method"
					+"\nTable Number = "+table
					+"\nTable Number = "+column);
		return null;
		}	
		double []cells = new double[nLines];
		for(int i=0; i< nLines; i++)
			try{
				cells[i] = ((Double)tables[table].getValueAt(i,column)).doubleValue();
			}
			catch(ClassCastException e){
					String msg = ""; 
					msg += "ERROR: "+e.getMessage(); 
					msg += "\n\n-----------------------"; 
					msg += "\n The value in the cell ("+i+", "+column+")"; 
					msg += "\n of the table "+tableNames[table]; 
					msg += "\n can not be converted to double"; 
					msg += "\n-----------------------"; 
					this.showErrorMessage(msg);
					this.showDialog();
					return null;
			}
		return cells;

	} //End of getInputTableColumnAsDouble

	/**
	 * Method to get an input table column.
	 *
	 * @param table the position of the specified table on the tables array
	 * @param column the number of the column
	 * @return vector with the values of the column typed by the user as integer
	 * @see javax.swing
	 */
	public int[] getInputTableColumnAsInt(int table, int column) {
		if(table < 0 || column < 0){
		this.showErrorMessage("Erron in getInputTable method"
					+"\nTable Number = "+table
					+"\nTable Number = "+column);
		return null;
		}	
		int []cells = new int[nLines];
		for(int i=0; i< nLines; i++)
			try{
				cells[i] = ((Integer)tables[table].getValueAt(i,column)).intValue();
			}
			catch(ClassCastException e){
					String msg = ""; 
					msg += "ERROR: "+e.getMessage(); 
					msg += "\n\n-----------------------"; 
					msg += "\n The value in the cell ("+i+", "+column+")"; 
					msg += "\n of the table "+tableNames[table]; 
					msg += "\n can not be converted to int"; 
					msg += "\n-----------------------"; 
					this.showErrorMessage(msg);
					this.showDialog();
					return null;
			}
		return cells;

	} //End of getInputTableColumnAsInt

	/**
	 * Method to get an input table column.
	 *
	 * @param table the position of the specified table on the tables array
	 * @param column the number of the column
	 * @return vector with the values of the column typed by the user as boolean
	 * @see javax.swing
	 */
	public boolean[] getInputTableColumnAsBoolean(int table, int column) {
		if(table < 0 || column < 0){
		this.showErrorMessage("Erron in getInputTableColumnASBoolean method"
					+"\nTable Number = "+table
					+"\nTable Number = "+column);
		return null;
		}	
		boolean []cells = new boolean[nLines];
		for(int i=0; i< nLines; i++)
			try{
				cells[i] = ((Boolean)tables[table].getValueAt(i,column)).booleanValue();
			}
			catch(ClassCastException e){
					String msg = ""; 
					msg += "ERROR: "+e.getMessage(); 
					msg += "\n\n-----------------------"; 
					msg += "\n The value in the cell ("+i+", "+column+")"; 
					msg += "\n of the table "+tableNames[table]; 
					msg += "\n can not be converted to int"; 
					msg += "\n-----------------------"; 
					this.showErrorMessage(msg);
					this.showDialog();
					return null;
			}
		return cells;

	} //End of getInputTableColumnAsBoolean


	/**
	 * Method to show the dialog.
	 *
	 * @return  an integer indicating the user option: 1 = Cancel, 0 = OK.
	 * @see javax.swing
	 */
	public int showDialog() {
		return super.showDialog(new JFrame(), title);
	}

	/**
	 * Method to be executed for the OK option.
	 *
	 */
	public void approvedPerform() {
		try {
			this.setVisible(false);
		} catch (Exception e) {
			Toolkit.getDefaultToolkit().beep();
			this.setVisible(false);
		}
	}

	private void showErrorMessage(String msg){
		JOptionPane.showMessageDialog(null,msg,"Error!",JOptionPane.INFORMATION_MESSAGE);
	}//End of showErrorMessage

}// End of class

//==== End of File
